<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数和Class.html</title>
</head>
<body>
    <script>
        function Fn1(){
            console.log('this',this) //this指向的是winod
            this.a = 10
            this.b = 20
            this.say = function (){
                console.log('say-fn1-inner',this)
            }
        }

        function Fn1 (username,age){
            console.log('this',this)
            this.suername=username
            this.age= age
        }
        //挂载到原型上的方法
        Fn1.prototype.say=function(){
            console.log('say-fn1-inner',`姓名：${this.username}，年龄:${this.age}`)
        }
        //实例化原型
        let tp1 = new Fn1('张三',18) // 张三 18
        let tp2 = new Fn1("李四", 20) //李四 20 
        console.log("==tp1.say是否等于tp2.say==", tp1.say === tp2.say)//true or false
        Fn1()
        let p1 = new Fn1(11,12)
        p1.say()
        
        class Fn2{
            a = 10
            b = 20
            say(){
                console.log('say-class-inner',this)
            }
        }
        let p2 = new Fn2()
        p2.say()

    </script>
</body>
</html>